<?php
//function sink().
/*$final_data = array();
function sink($createDate,$updateDate)
{

$query="SELECT * FROM sinklession where createdDate>='$createDate' && updateDate>='$updateDate'"; 
if ($query_run = mysql_query($query))
    { 
        $i=0;
        while($query_row = mysql_fetch_assoc($query_run)) 
        { 
            $LessionId = $query_row ['LessionId'];
			$LessonName = $query_row ['LessionName'];
			$CourseId = $query_row ['CourseId'];
			$CourseLessonNo = $query_row ['CourseLessonNo'];
			$UpdatedDate = $query_row ['UpdateDate'];
			$CreatedDate = $query_row ['CreatedDate'];
			
			// store data in Array
			
            $data = array('LessionId'=>$LessionId,'LessonName'=>$LessonName,'CourseId'=>$CourseId,'CourseLessonNo'=>$CourseLessonNo,'UpdatedDate'=>$UpdatedDate,'CreatedDate'=>$CreatedDate); 
            $final_data[$i]=$data;
            $i++;
        } 
	 // Print data in json format using json_encode php function.
	 
           print(json_encode($final_data)); 
    }else{
     echo mysql_error(); 
    }
}// end function sink().

// Function lessonDetail().
function lessonDetail($CourseId,$CourseLessionNo,$UpdateDate,$CreateDate)
{
	$final_lessondata = array();
	$query="select * from lessiondetail where CourseId='$CourseId' && CourseLessionNo='$CourseLessionNo' && UpdateDate>='$UpdateDate' && CreateDate>='$CreateDate'";
	if($result=mysql_query($query))
	{
		$i=0;
		while($row=mysql_fetch_assoc($result))
		{
			$LessionId=$row['LessionId'];
			$LessionName=$row['LessionName'];
			$CourseId=$row['CourseId'];
			$CourseLessionNo=$row['CourseLessionNo'];
			$LessionText=$row['LessionText'];
			$LessionAudioPath=$row['LessionAudioPath'];
			$LessionVedioPath=$row['LessionVedioPath'];
			$UpdateDate=$row['UpdateDate'];
			$CreateDate=$row['CreateDate'];
			
			// get data in Array format
			
			$data = array('LessionId'=>$LessionId,'LessionName'=>$LessionName,'CourseId'=>$CourseId,'CourseLessionNo'=>$CourseLessionNo,'LessionText'=>$LessionText,'LessionAudioPath'=>$LessionAudioPath,'LessionVedioPath'=>$LessionVedioPath,'UpdateDate'=>$UpdateDate,'CreateDate'=>$CreateDate);
			// store vale in array.
            $final_lessondata[$i]=$data;
            $i++;
		}
		print(json_encode($final_lessondata));
	}
	else
	{
     echo mysql_error(); 
    }
	// print Data in json Format.
	   
}// end function lessonDetail().
*/
function getCourse($from_date,$to_date)
{
if($from_date=="" && $to_date=="")
{
	$query="select * from sinkcourse";
	if ($query_run = mysql_query($query))
    { 
        $i=0;
        while($query_row = mysql_fetch_assoc($query_run)) 
        { 
            $CourseId = $query_row ['CourseId'];
			$CourseName = $query_row ['CourseName'];
			$CourseCategory = $query_row ['CourseCategory'];
			$UpdateDate = $query_row ['UpdateDate'];
			$CreatedDate = $query_row ['CreatedDate'];
			
			// store data in Array
			
            $data = array('CourseId'=>$CourseId,'CourseName'=>$CourseName,'CourseCategory'=>$CourseCategory,'UpdateDate'=>$UpdateDate,'CreatedDate'=>$CreatedDate); 
            $final_data[$i]=$data;
            $i++;
        } 
	 // Print data in json format using json_encode php function.
		print(json_encode($final_data));
	   }else{
     echo mysql_error(); 
    }
}
else
{
	if($query="select * from sinkcourse where UpdateDate>='$from_date'&& CreatedDate>='$to_date'">=1)
	{
		echo "Success";
	}
	else
	{
		echo "fail";
	}
}
}
/*$final_data=array();
if(isset($from_date) && isset($to_date))
{
	$query="select * from sinkcourse";
	if ($query_run = mysql_query($query))
    { 
        $i=0;
        while($query_row = mysql_fetch_assoc($query_run)) 
        { 
            $CourseId = $query_row ['CourseId'];
			$CourseName = $query_row ['CourseName'];
			$CourseCategory = $query_row ['CourseCategory'];
			$UpdateDate = $query_row ['UpdateDate'];
			$CreatedDate = $query_row ['CreatedDate'];
			
			// store data in Array
			
            $data = array('CourseId'=>$CourseId,'CourseName'=>$CourseName,'CourseCategory'=>$CourseCategory,'UpdateDate'=>$UpdateDate,'CreatedDate'=>$CreatedDate); 
            $final_data[$i]=$data;
            $i++;
        } 
	 // Print data in json format using json_encode php function.
		print(json_encode($final_data));
	   }else{
     echo mysql_error(); 
    }
}
else if($query="select * from sinkcourse where createdDate>='$from_date' && UpdateDate>='$to_date'">=1)
{
	
if ($query_run = mysql_query($query))
    { 
        $i=0;
        while($query_row = mysql_fetch_assoc($query_run)) 
        { 
            $CourseId = $query_row ['CourseId'];
			$CourseName = $query_row ['CourseName'];
			$CourseCategory = $query_row ['CourseCategory'];
			$UpdateDate = $query_row ['UpdateDate'];
			$CreatedDate = $query_row ['CreatedDate'];
			
			// store data in Array
			
            $data = array('CourseId'=>$CourseId,'CourseName'=>$CourseName,'CourseCategory'=>$CourseCategory,'UpdateDate'=>$UpdateDate,'CreatedDate'=>$CreatedDate); 
            $final_data[$i]=$data;
            $i++;
        } 
	 // Print data in json format using json_encode php function.
		print(json_encode($final_data));
	   }else{
     echo mysql_error(); 
    }
	
}
else
{
	echo "null";
}
}*/

// simple code
/*
if($query="SELECT * FROM sinkcourse where createdDate>'$CreatedDate' && UpdateDate>'$UpdateDate'">=1)
{
if ($query_run = mysql_query($query))
    { 
        $i=0;
        while($query_row = mysql_fetch_assoc($query_run)) 
        { 
            $CourseId = $query_row ['CourseId'];
			$CourseName = $query_row ['CourseName'];
			$CourseCategory = $query_row ['CourseCategory'];
			$UpdateDate = $query_row ['UpdateDate'];
			$CreatedDate = $query_row ['CreatedDate'];
			
			// store data in Array
			
            $data = array('CourseId'=>$CourseId,'CourseName'=>$CourseName,'CourseCategory'=>$CourseCategory,'UpdateDate'=>$UpdateDate,'CreatedDate'=>$CreatedDate); 
            $final_data[$i]=$data;
            $i++;
        } 
	 // Print data in json format using json_encode php function.
		print(json_encode($final_data));
	   }else{
     echo mysql_error(); 
    }
}
}
}*/
?>